﻿<%-- 
    Copyright (C) Binod Nepal, Planet Earth Solutions Pvt. Ltd., Kathmandu.
	Released under the terms of the GNU General Public License, GPL, 
	as published by the Free Software Foundation, either version 3 
	of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
--%>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MixNP.Web.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PESConnectionString %>"
        SelectCommand="SELECT * FROM dbo.Cities ORDER BY CityId;"></asp:SqlDataSource>
    <div id="dd" class="wrapper-dropdown-5" tabindex="1">
        <span>
            <asp:Literal ID="CityLiteral" runat="server" Text="Kathmandu" />
        </span>
        <ul class="dropdown">
            <asp:Repeater ID="CityRepeater" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="CityRepeater_ItemCommand">
                <ItemTemplate>
                    <li>
                        <asp:LinkButton runat="server" CommandArgument='<%# Eval("CityId") %>'
                            CommandName="CityCommand" Text='<%# Eval("CityName") %>' />
                    </li>
                </ItemTemplate>
            </asp:Repeater>
        </ul>
    </div>
    </form>
</body>
</html>
<script runat="server">
    public void CityRepeater_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        LinkButton s = sender as LinkButton;
        if (s != null)
        {
            if (!string.IsNullOrWhiteSpace(s.CommandArgument))
            {
                Session["CityId"] = s.CommandArgument;
            }

            if (!string.IsNullOrWhiteSpace(s.Text))
            {
                Session["City"] = s.Text;
            }
        }
    }
    
</script>
